package com.ygglxt.servlet;

import com.google.gson.Gson;
import com.ygglxt.entity.GangWei;
import com.ygglxt.entity.YuanGong;
import com.ygglxt.service.GangWeiService;
import com.ygglxt.service.YuanGongService;
import com.ygglxt.util.Result;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

@WebServlet(name = "GangWeiServlet",urlPatterns = "/GangWeiServlet")
public class GangWeiServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        GangWeiService service=new GangWeiService();
        //这里类型要设置未text/json
        response.setContentType("text/json;charset=utf-8");
        List<GangWei> memberList=service.getListAll();
        PrintWriter writer = response.getWriter();
        writer.write(new Gson().toJson(Result.reOk("ok",memberList)));

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }




}
